const {normalize, format, parse, relative, delimiter} = require('path');
let filepath = '/tmp/demo/js/test.js';

let index= 0;

function compare(desc, callback){
    console.log('[用例%d]: %s', ++index, desc);
    callback();
    console.log('\n');
}

compare('路径为空', function(){
    console.log(normalize(''));
});
compare('路径结尾是否带/', function(){
    console.log(normalize('/tmp/demo/js/upload/'));
});
compare('重复的/', function(){
    console.log(normalize('/tmp/demo//js/upload'));
});
compare('路径带..', function(){
    console.log(normalize('/tmp/demo/js/upload/..'));
});
compare('相对路径', function(){
    console.log(normalize('./demo/js/upload/'));
    console.log(normalize('demo/js/upload/'));
});
compare('不常用边界', function(){
    console.log(normalize('./..'));
    console.log(normalize('..'));
    console.log(normalize('../'));
    console.log(normalize('/../'));
    console.log(normalize('/..'));
});

let p1 = format({
    root: '/tmp/',
    base: 'hello.js'
});
console.log(p1);

let p2 = format({
    dir: '/tmp',
    name: 'hello',
    ext: '.js'
});

let p = relative('/tmp', '../src/test.js');
console.log(p);

var p3 = relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb');
console.log(p3);

var p4 = relative('/data/demo', '');
console.log(p4)

console.log(process.env.PATH.split(delimiter));